/**
 * @author helio
 */
if (!SALE.setting) SALE.setting = {}

if (!SALE.setting.PasswordModifyPanel) {
	SALE.setting.PasswordModifyPanel = Ext.extend(SALE.basicGridPanel, {
	
		layout: 'fit',
		border: false,
		bodyStyle : 'background-color: transparent;', 
		initComponent: function(){
			
			this.inputForm = new Ext.FormPanel({
				labelWidth: 60,
				border: false,
				autoHeight: true,
				buttonAlign: 'center',
				defaultType: 'textfield',
				bodyStyle : 'background-color: transparent;', 
												
				items: [{
					inputType: 'password',
					fieldLabel: '原密码',
                	name: 'old_pass',
                	allowBlank: false,
                	anchor:'80%'	
				},{	
					inputType: 'password',
					fieldLabel: '新密码',
                	name: 'new_pass',
                	id: 'passwd',
                	allowBlank: false,
                	anchor:'80%'	
				},{
					inputType: 'password',
					vtype: 'password',
					fieldLabel: '确认密码',
                	initialPassField: 'passwd',
                	allowBlank: false,
                	anchor:'80%'			
				}],
		      
				
				buttons: [{
		            text: '修改',
		            iconCls: 'save',
					listeners: {
						"click": this.onSave.createDelegate(this)
					}
		        }]
			});
			
			this.items = this.inputForm;
			
			SALE.setting.PasswordModifyPanel.superclass.initComponent.call(this);
		},
						
		onSave : function() {
			if(this.inputForm.form.isValid()) {
				var old_pass = this.inputForm.form.findField("old_pass").getValue();
				var new_pass = this.inputForm.form.findField("new_pass").getValue();
				var password = {
					'old_pass':old_pass,
					'new_pass':new_pass
				};
				SALE.Action.passwordModifyAction(this.close.createDelegate(this), password);				
			}
		}
		
	});
	
	Ext.reg('passwordmodify', SALE.setting.PasswordModifyPanel);
}

function showPasswordModifyWindow() {
	this.inputWin = new Ext.Window({
 		
	 	title: '修改密码',
		closable: true,
		frame: true,
		//plain:true,
		width: 400,
		height: 260,
		layout: 'border',
		closeAction :'close',
		bodyStyle: "padding:10px;",	
		items: [{
			region: 'north',
			border: false,
			bodyStyle : 'background-color: transparent;', 
			height: 60,
            html: '<div style="text-align:center;"><h1 style="float:inherit;">修改密码</h1><hr/>	</div>'
		}, {
			region: 'center',
			margins: '20 20 20 20',
			xtype : "passwordmodify"
		}]
	});
	
	this.inputWin.show();
}